package com.qf.zyh.web.controller;

import com.qf.zyh.common.ResponseResult;
import com.qf.zyh.common.ResultType;
import com.qf.zyh.entity.ApiSystemparam;
import com.qf.zyh.services.SystemparatersServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/systemparaters")
public class SystemparatersController {
    @Autowired
    private SystemparatersServices systemparatersServices;
    @RequestMapping("/table")
    public ResultType table(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "10") Integer limit, String name, Integer state){
        return systemparatersServices.table(page,limit,name,state);
    }
    @RequestMapping("/del")
    public ResponseResult delApi(Integer[] ids){
        try {
            return systemparatersServices.delApi(ids);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.getFail("删除失败");
    }
    @RequestMapping("/add")
    public ResponseResult addApi(ApiSystemparam api){
        try {
            return systemparatersServices.addApi(api);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.getFail("新增失败");
    }
    @RequestMapping("/update")
    public ResponseResult updateApi(ApiSystemparam api){
        try {
            return systemparatersServices.updateApi(api);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.getFail("修改失败");
    }

}
